<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: guzhe
  Date: 2020/12/8
  Time: 15:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
//获取用户名和密码
    String userName=request.getParameter("username");
    String password=request.getParameter("password");
    Class.forName("com.mysql.jdbc.Driver");
    Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/software18?serverTimezone=Asia/Shanghai","root","489436gzl");
    String sql="select * from tb1_user where username=? and password=?";
    PreparedStatement pst=conn.prepareStatement(sql);
    pst.setString(1,userName);
    pst.setString(2,password);
    ResultSet resultset=pst.executeQuery();
    if(resultset.next()){
        out.print("用户名密码成功");
    }else{
        out.print("用户名错误");
    }

//   if(userName!=null&&userName.equals("zhangsan")){
//       if(password!=null&&password.equals("123456")){
//           out.print("用户名和密码正确");
//       }else{
//           out.print("密码错误！");
//       }}
//       else {
//           out.print("用户名错误！");
//
//   }
%>